Closures inherit #[optimize] from the enclosing function by default.#158901
Closures inherit #[optimize] from the enclosing function by default.#158901veluca93 wants to merge 1 commit into
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
Waiting on t-lang per #157273 (comment) |
|
The lang team discussed this change today and was in favor: #157562 (comment) |
|
I don't believe this is blocked on lang anymore, but I don't think I can remove the tag myself. |
|
Reminder, once the PR becomes ready for a review, use |
3c5ebd5 to
f24fa6f
Compare
|
@rustbot ready |
| //! Ensure that `#[optimize]` applied to an outer function is inherited by closures | ||
| //! and their coercion shims, unless overridden by an explicit `#[optimize]` on the closure. | ||
|
|
||
| //@ compile-flags: -Copt-level=3 |
There was a problem hiding this comment.
suggestion: I think you can do this as a -C no-prepopulate-passes test, right? Since we're the ones setting the attributes?
That would mean you'd have no need to handle all the attributes introduced today (or could be introduced in the future) in the CHECK lines, which would hopefully let it be a touch simpler.
(Might even be able to remove the side_effect functions because with no LLVM optimizations going on that shouldn't matter? Or at least only need one of them without also needing -Z merge-functions=disabled.)
| #![crate_type = "lib"] | ||
|
|
||
| // CHECK-DAG: define{{.*}}void {{.*}}test_none{{.*}}call_once{{.*}}#[[ATTR_NONE:[0-9]+]] | ||
| // CHECK-DAG: define{{.*}}void {{.*}}test_none{{.*}}B{{[0-9]+}}_() {{.*}}#[[ATTR_NONE]] |
There was a problem hiding this comment.
Possibly a silly question: what's that B from?
(I get worried about anything too specific in name checks because we've been bitten before by people doing things like %[[FOO]].0 and depending on the exact internal LLVM naming of SRoA results and such. This is probably not that bad, but I'm confused what it is, so...)
Tracking issue: #54882
Stabilization PR: #157273